<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
    const data = [ {
        id:1,
        name:'Huawei Mate50 pro',
        price:6998
    },{
        id:2,
        name:'Apple 18',
        price:12998
    },{
        id:3,
        name:'xiaomi 12',
        price:3998
    }]
//**************forEach for key in 遍历****************//
    const arr = []
    data.forEach((item,idex)=>{
        arr[idex] = {}
        for(var key in item){
            arr[idex][key] = item[key]
        }
    })
    console.log(arr)
      
//**************forEach for key in 遍历****************//
    const arr1 = []
    data.forEach((item,idex)=>{
        arr1[idex] = {}
        arr1[idex] = { ...data[idex]}
    })
    console.log(arr1)

    </script>
</body>
</html>